//一个数组中只有0、1、2，现在进行数组分块，先放0，再放1，最后放2
#include<iostream>
#include<vector>
using namespace std;

vector<int> a(1e5);

int main()
{
    int n; cin >> n;
    for(int i = 0; i < n; i ++) cin >> a[i];

    int i = 0, left = -1, right = n;
    while(i < right)
    {
        if(a[i] == 2) swap(a[i], a[-- right]);
        else if(a[i] == 1) i ++;
        else if(a[i] == 0) swap(a[++ left], a[i ++]);
    }

    for(int i = 0; i < n; i ++)
        cout << a[i] << " ";
    return 0;
}